﻿$(document).ready(function () {
    $('[data-toggle="tooltip"]').tooltip();
});
$(document).ready(function () {

    $("#btn_checkin").on("click", function () {
        $(".voice").remove();
        var date = "";
        if ($("#check_date").length) {
            date=document.getElementById("check_date").value;
        }
        var id = document.getElementById("dsnv").value;
        var temp = document.getElementById("check-in").innerHTML;
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                $(".voice").remove();
                document.getElementById("check-in").innerHTML = xhttp.responseText + temp;
                $('#check-in').stop().animate({ scrollTop: 0 }, 500);
                setTimeout("$('.error').fadeOut()", 2500);
                $(".btn_edit_check").on("click", function () {
                    document.getElementById("suadiemdanh").style.display = 'block';
                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                            document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                            $(document).ready(function () {
                                $('[data-toggle="popover"]').popover();
                            });
                            $(document).ready(function () {
                                $(".btn_edited_check").on("click", function () {
                                    var checkin = document.getElementById("edit_checkin").value;
                                    var absent = "0";
                                    if ($("#absent-edit").is(":checked")) {
                                        absent = "1";
                                    }
                                    var overtime = "0";
                                    if ($("#overtime").is(":checked")) {
                                        overtime = "1";
                                    }
                                    var xhttp;
                                    xhttp = new XMLHttpRequest();
                                    xhttp.onreadystatechange = function () {
                                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                                            document.getElementById(id).innerHTML = xhttp.responseText;
                                            document.getElementById("suadiemdanh").style.display = 'none';
                                            $(".btn_edit_check").on("click", function () {
                                                document.getElementById("suadiemdanh").style.display = 'block';
                                                var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                var xhttp;
                                                xhttp = new XMLHttpRequest();
                                                xhttp.onreadystatechange = function () {
                                                    if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                        document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                                                        $(document).ready(function () {
                                                            $('[data-toggle="popover"]').popover();
                                                        });
                                                        $(document).ready(function () {
                                                            $(".btn_edited_check").on("click", function () {
                                                                var checkin = document.getElementById("edit_checkin").value;
                                                                var absent = "0";
                                                                if ($("#absent-edit").is(":checked")) {
                                                                    absent = "1";
                                                                }
                                                                var overtime = "0";
                                                                if ($("#overtime").is(":checked")) {
                                                                    overtime = "1";
                                                                }
                                                                var xhttp;
                                                                xhttp = new XMLHttpRequest();
                                                                xhttp.onreadystatechange = function () {
                                                                    if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                                        document.getElementById(id).innerHTML = xhttp.responseText;
                                                                        document.getElementById("suadiemdanh").style.display = 'none';
                                                                    }
                                                                };
                                                                xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id + "&checkin=" + checkin + "&absent=" + absent+"&overtime="+overtime, true);
                                                                xhttp.send();
                                                            });
                                                        });
                                                    }
                                                };
                                                xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
                                                xhttp.send();

                                            });
                                            $(".btn_del_check").on("click", function () {
                                                var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                document.getElementById("del_check_id").innerHTML = id;

                                                document.getElementById("del_check").style.display = 'block';
                                            });
                                        }
                                    };
                                    xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id + "&checkin=" + checkin + "&absent=" + absent + "&overtime="+overtime, true);
                                    xhttp.send();
                                });
                                $(".btn_del_check").on("click", function () {
                                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                    document.getElementById("del_check_id").innerHTML = id;

                                    document.getElementById("del_check").style.display = 'block';
                                });
                            });
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
                    xhttp.send();
                });
                $(".btn_del_check").on("click", function () {
                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                    document.getElementById("del_check_id").innerHTML = id;

                    document.getElementById("del_check").style.display = 'block';
                });
                $(".btn_confirm_check").on("click", function () {
                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                    $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                    $(this).prop('title', 'Đã xác nhận');
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                    xhttp.send();
                });
            }
        };
        xhttp.open("GET", "../ajax/asp/check_in_admin.aspx?id=" + id +"&date="+date, true);
        xhttp.send();
    });
    $("#btn_checkout").on("click", function () {
        var id = document.getElementById("dsnv").value;
        //var admin_id = document.getElementsByClassName(id)[1].style.display = 'none';
        
        //var size = $("#10").position().top;
        //var check = $("#check-in").position().top;
        
        $(".voice").remove();
        var temp = document.getElementById("check-in").innerHTML;
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                $(".voice").remove();
                $('#check-in').stop().animate({ scrollTop: 0 }, 500);
                document.getElementById("check-in").innerHTML = xhttp.responseText + temp;
                if (xhttp.responseText.indexOf("<li") != -1)
                    document.getElementsByClassName(id)[1].remove();
                setTimeout("$('.error').fadeOut()", 2500);
                $(".btn_edit_check").on("click", function () {
                    document.getElementById("suadiemdanh").style.display = 'block';
                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                            document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                            $(document).ready(function () {
                                $('[data-toggle="popover"]').popover();
                            });
                            $(document).ready(function () {
                                $(".btn_edited_check").on("click", function () {
                                    var checkin = document.getElementById("edit_checkin").value;
                                    var absent = "0";
                                    if ($("#absent-edit").is(":checked")) {
                                        absent = "1";
                                    }
                                    var overtime = "0";
                                    if ($("#overtime").is(":checked")) {
                                        overtime = "1";
                                    }
                                    var xhttp;
                                    xhttp = new XMLHttpRequest();
                                    xhttp.onreadystatechange = function () {
                                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                                            document.getElementById(id).innerHTML = xhttp.responseText;
                                            document.getElementById("suadiemdanh").style.display = 'none';
                                            $(".btn_edit_check").on("click", function () {
                                                document.getElementById("suadiemdanh").style.display = 'block';
                                                var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                var xhttp;
                                                xhttp = new XMLHttpRequest();
                                                xhttp.onreadystatechange = function () {
                                                    if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                        document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                                                        $(document).ready(function () {
                                                            $('[data-toggle="popover"]').popover();
                                                        });
                                                        $(document).ready(function () {
                                                            $(".btn_edited_check").on("click", function () {
                                                                var checkin = document.getElementById("edit_checkin").value;
                                                                var absent = "0";
                                                                if ($("#absent-edit").is(":checked")) {
                                                                    absent = "1";
                                                                }
                                                                var overtime = "0";
                                                                if ($("#overtime").is(":checked")) {
                                                                    overtime = "1";
                                                                }
                                                                var xhttp;
                                                                xhttp = new XMLHttpRequest();
                                                                xhttp.onreadystatechange = function () {
                                                                    if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                                        document.getElementById(id).innerHTML = xhttp.responseText;
                                                                        document.getElementById("suadiemdanh").style.display = 'none';
                                                                    }
                                                                };
                                                                xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id + "&checkin=" + checkin + "&absent=" + absent +"&overtime="+overtime, true);
                                                                xhttp.send();
                                                            });
                                                        });
                                                    }
                                                };
                                                xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
                                                xhttp.send();

                                            });
                                            $(".btn_del_check").on("click", function () {
                                                var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                document.getElementById("del_check_id").innerHTML = id;

                                                document.getElementById("del_check").style.display = 'block';
                                            });
                                        }
                                    };
                                    xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id + "&checkin=" + checkin + "&absent=" + absent+"&overtime="+overtime, true);
                                    xhttp.send();
                                });
                                $(".btn_del_check").on("click", function () {
                                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                    document.getElementById("del_check_id").innerHTML = id;

                                    document.getElementById("del_check").style.display = 'block';
                                });
                            });
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
                    xhttp.send();
                });
                $(".btn_del_check").on("click", function () {
                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                    document.getElementById("del_check_id").innerHTML = id;

                    document.getElementById("del_check").style.display = 'block';
                });
                $(".btn_confirm_check").on("click", function () {
                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                    $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                    $(this).prop('title', 'Đã xác nhận');
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                    xhttp.send();
                });
            }
        };
        xhttp.open("GET", "../ajax/asp/check_out_admin.aspx?id=" + id, true);
        xhttp.send();
    });

    $(".btn_edit_check").on("click", function () {
        document.getElementById("suadiemdanh").style.display = 'block';
        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                $(document).ready(function () {
                    $('[data-toggle="popover"]').popover();
                });
                $(document).ready(function () {
                    $(".btn_edited_check").on("click", function () {
                        var checkin = document.getElementById("edit_checkin").value;
                        var absent = "0";
                        if ($("#absent-edit").is(":checked")) {
                            absent = "1";
                        }
                        var overtime = "0";
                        if ($("#overtime").is(":checked")) {
                            overtime = "1";
                        }
                        var xhttp;
                        xhttp = new XMLHttpRequest();
                        xhttp.onreadystatechange = function () {
                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                document.getElementById(id).innerHTML = xhttp.responseText;
                                document.getElementById("suadiemdanh").style.display = 'none';
                                $(document).ready(function () {
                                    $(".btn_edit_check").on("click", function () {
                                        document.getElementById("suadiemdanh").style.display = 'block';
                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                        var xhttp;
                                        xhttp = new XMLHttpRequest();
                                        xhttp.onreadystatechange = function () {
                                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                                                $(document).ready(function () {
                                                    $('[data-toggle="popover"]').popover();
                                                });
                                                $(document).ready(function () {
                                                    $(".btn_edited_check").on("click", function () {
                                                        var checkin = document.getElementById("edit_checkin").value;
                                                        var absent = "0";
                                                        if ($("#absent-edit").is(":checked")) {
                                                            absent = "1";
                                                        }
                                                        var overtime = "0";
                                                        if ($("#overtime").is(":checked")) {
                                                            overtime = "1";
                                                        }
                                                        var xhttp;
                                                        xhttp = new XMLHttpRequest();
                                                        xhttp.onreadystatechange = function () {
                                                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                                document.getElementById(id).innerHTML = xhttp.responseText;
                                                                document.getElementById("suadiemdanh").style.display = 'none';
                                                                $(document).ready(function () {
                                                                    $(".btn_del_check").on("click", function () {
                                                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                                        document.getElementById("del_check_id").innerHTML = id;

                                                                        document.getElementById("del_check").style.display = 'block';
                                                                    });
                                                                    $(".btn_confirm_check").on("click", function () {
                                                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                                        $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                                                                        $(this).prop('title', 'Đã xác nhận');
                                                                        var xhttp;
                                                                        xhttp = new XMLHttpRequest();
                                                                        xhttp.onreadystatechange = function () {
                                                                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                                            }
                                                                        };
                                                                        xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                                                                        xhttp.send();
                                                                    });
                                                                });
                                                            }
                                                        };
                                                        xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id + "&checkin=" + checkin + "&absent=" + absent+"&overtime="+overtime, true);
                                                        xhttp.send();
                                                    });
                                                    $(".btn_del_check").on("click", function () {
                                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                        document.getElementById("del_check_id").innerHTML = id;

                                                        document.getElementById("del_check").style.display = 'block';
                                                    });
                                                    $(".btn_confirm_check").on("click", function () {
                                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                        $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                                                        $(this).prop('title', 'Đã xác nhận');
                                                        var xhttp;
                                                        xhttp = new XMLHttpRequest();
                                                        xhttp.onreadystatechange = function () {
                                                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                            }
                                                        };
                                                        xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                                                        xhttp.send();
                                                    });
                                                });
                                            }
                                        };
                                        xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
                                        xhttp.send();

                                    });
                                    $(".btn_del_check").on("click", function () {
                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                        document.getElementById("del_check_id").innerHTML = id;

                                        document.getElementById("del_check").style.display = 'block';
                                    });
                                    $(".btn_confirm_check").on("click", function () {
                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                        $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                                        $(this).prop('title', 'Đã xác nhận');
                                        var xhttp;
                                        xhttp = new XMLHttpRequest();
                                        xhttp.onreadystatechange = function () {
                                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                            }
                                        };
                                        xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                                        xhttp.send();
                                    });
                                });
                                
                            }
                        };
                        xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id+"&checkin="+checkin +"&absent="+absent+"&overtime="+overtime, true);
                        xhttp.send();
                    });
                    $(".btn_del_check").on("click", function () {
                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                        document.getElementById("del_check_id").innerHTML = id;

                        document.getElementById("del_check").style.display = 'block';
                    });
                });
            }
        };
        xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
        xhttp.send();
    });

    $("#btn_change_check").on("click", function () {
        var date = document.getElementById("check_date").value;
        if (date == "")
            alert("Sai định dạng ngày!");
        else {
            var xhttp;
            xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function () {
                if (xhttp.readyState == 4 && xhttp.status == 200) {
                    document.getElementById("check-in").innerHTML = xhttp.responseText;
                    $(".btn_edit_check").on("click", function () {
                        document.getElementById("suadiemdanh").style.display = 'block';
                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                        var xhttp;
                        xhttp = new XMLHttpRequest();
                        xhttp.onreadystatechange = function () {
                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                                $(document).ready(function () {
                                    $('[data-toggle="popover"]').popover();
                                });
                                $(document).ready(function () {
                                    $(".btn_edited_check").on("click", function () {
                                        var checkin = document.getElementById("edit_checkin").value;
                                        var absent = "0";
                                        if ($("#absent-edit").is(":checked")) {
                                            absent = "1";
                                        }
                                        var overtime = "0";
                                        if ($("#overtime").is(":checked")) {
                                            overtime = "1";
                                        }
                                        var xhttp;
                                        xhttp = new XMLHttpRequest();
                                        xhttp.onreadystatechange = function () {
                                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                document.getElementById(id).innerHTML = xhttp.responseText;
                                                document.getElementById("suadiemdanh").style.display = 'none';
                                                $(".btn_edit_check").on("click", function () {
                                                    document.getElementById("suadiemdanh").style.display = 'block';
                                                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                    var xhttp;
                                                    xhttp = new XMLHttpRequest();
                                                    xhttp.onreadystatechange = function () {
                                                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                            document.getElementById("suadiemdanh").innerHTML = xhttp.responseText;
                                                            $(document).ready(function () {
                                                                $('[data-toggle="popover"]').popover();
                                                            });
                                                            $(document).ready(function () {
                                                                $(".btn_edited_check").on("click", function () {
                                                                    var checkin = document.getElementById("edit_checkin").value;
                                                                    var absent = "0";
                                                                    if ($("#absent-edit").is(":checked")) {
                                                                        absent = "1";
                                                                    }
                                                                    var overtime = "0";
                                                                    if ($("#overtime").is(":checked")) {
                                                                        overtime = "1";
                                                                    }
                                                                    var xhttp;
                                                                    xhttp = new XMLHttpRequest();
                                                                    xhttp.onreadystatechange = function () {
                                                                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                                            document.getElementById(id).innerHTML = xhttp.responseText;
                                                                            document.getElementById("suadiemdanh").style.display = 'none';
                                                                        }
                                                                    };
                                                                    xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id + "&checkin=" + checkin + "&absent=" + absent+"&overtime="+overtime, true);
                                                                    xhttp.send();
                                                                });
                                                            });
                                                        }
                                                    };
                                                    xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
                                                    xhttp.send();

                                                });
                                                $(".btn_del_check").on("click", function () {
                                                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                    document.getElementById("del_check_id").innerHTML = id;

                                                    document.getElementById("del_check").style.display = 'block';
                                                });
                                                $(".btn_confirm_check").on("click", function () {
                                                    var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                                    $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                                                    $(this).prop('title', 'Đã xác nhận');
                                                    var xhttp;
                                                    xhttp = new XMLHttpRequest();
                                                    xhttp.onreadystatechange = function () {
                                                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                                                        }
                                                    };
                                                    xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                                                    xhttp.send();
                                                });
                                            }
                                        };
                                        xhttp.open("GET", "../ajax/asp/edited_check_admin.aspx?id=" + id + "&checkin=" + checkin + "&absent=" + absent+"&overtime="+overtime, true);
                                        xhttp.send();
                                    });
                                    $(".btn_del_check").on("click", function () {
                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                        document.getElementById("del_check_id").innerHTML = id;

                                        document.getElementById("del_check").style.display = 'block';
                                    });
                                    $(".btn_confirm_check").on("click", function () {
                                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                                        $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                                        $(this).prop('title', 'Đã xác nhận');
                                        var xhttp;
                                        xhttp = new XMLHttpRequest();
                                        xhttp.onreadystatechange = function () {
                                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                                            }
                                        };
                                        xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                                        xhttp.send();
                                    });
                                });
                            }
                        };
                        xhttp.open("GET", "../ajax/asp/edit_check_admin.aspx?id=" + id, true);
                        xhttp.send();
                    });
                    $(".btn_del_check").on("click", function () {
                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                        document.getElementById("del_check_id").innerHTML = id;

                        document.getElementById("del_check").style.display = 'block';
                    });
                    $(".btn_confirm_check").on("click", function () {
                        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
                        $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
                        $(this).prop('title', 'Đã xác nhận');
                        var xhttp;
                        xhttp = new XMLHttpRequest();
                        xhttp.onreadystatechange = function () {
                            if (xhttp.readyState == 4 && xhttp.status == 200) {
                            }
                        };
                        xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
                        xhttp.send();
                    });
                }
            };
            xhttp.open("GET", "../ajax/asp/get_check_in_admin.aspx?date=" + date, true);
            xhttp.send();
        }
    });

    $(".btn_del_check").on("click", function () {
        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
        document.getElementById("del_check_id").innerHTML = id;

        document.getElementById("del_check").style.display = 'block';
    });

    $("#btn_deleted_check").on("click", function () {
        var id = document.getElementById("del_check_id").innerHTML;

        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                document.getElementById(id).remove();
                document.getElementById("del_check").style.display = 'none';
            }
        };
        xhttp.open("GET", "../ajax/asp/del_check_admin.aspx?id=" + id, true);
        xhttp.send();
    });

    $(".btn_confirm_check").on("click", function () {
        var id = this.parentElement.parentElement.getElementsByClassName("check_id")[0].innerHTML;
        $(this).removeClass("btn_confirm_check").removeClass("w3-hover-text-teal").addClass("w3-text-teal");
        $(this).prop('title', 'Đã xác nhận');
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
            }
        };
        xhttp.open("GET", "../ajax/asp/staff/confirm_check.aspx?id=" + id, true);
        xhttp.send();
    });
});
function last_week() {
    $("#this_week").fadeOut();
    $("#last_week").fadeIn();
}

function this_week() {
    $("#this_week").fadeIn();
    $("#last_week").fadeOut();
}
function next_week() {
    $("#this_week").fadeOut();
    $("#next_week").fadeIn();
}
function pri_week() {
    $("#this_week").fadeIn();
    $("#next_week").fadeOut();
}
function load_week(id)
{
    document.getElementById("this_week").innerHTML = '<div id="loading"><div id="loading-center-absolute"><div class="object w3-text-teal" id="object_four"></div><div class="object w3-text-teal" id="object_three"></div><div class="object w3-text-teal" id="object_two"></div><div class="object w3-text-teal" id="object_one"></div></div></div>';
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("this_week").innerHTML = xhttp.responseText;
        }
    };
    xhttp.open("GET", "../ajax/asp/working/load_working.aspx?id=" + id, true);
    xhttp.send();
}
setInterval("total_access()", "1000");
setInterval("online_access()", "1000");
function total_access() {
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("total_access").innerHTML = xhttp.responseText;
        }
    };
    xhttp.open("GET", "../ajax/asp/default/totalaccess.aspx", true);
    xhttp.send();
}

function online_access()
{
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("online_access").innerHTML = xhttp.responseText;
        }
    };
    xhttp.open("GET", "../ajax/asp/default/onlineaccess.aspx", true);
    xhttp.send();
}